<?php
/**
 * @testdbDonor.php
 * Controls database operations on the testdbDonor table.
 *
 * Copyright 2011 by Matthew Wakim.  This program is part of Donate.
 * Donate is free software.  It comes with absolutely no warranty.
 * You can redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software Foundation
 * (see <http://www.gnu.org/licenses/ for more information).
 * 
 * @version March 5th 2011
 * @author Matthew Wakim
 */
include_once(dirname(__FILE__).'/../tests/dbDonors.php');
class testdbDoners extends UnitTestCase {
      function testdbDonersModule() {
/** add a doner
*/
$m = new Doner("1", "Street", "city", "state", "zip", "phone", "fax", "eMail" );
$this->assertTrue(add_Doner($m));

/** add an DonerID, Doner Type
*/
$a = new Doner("2", "22 Easy Street", "Manchester" , "NH", "02029", "111-111-1111", "222-222-2222", "testing@test.com" );
$this->assertTrue(add_Doner($a));

/** add a DonerID, DonerType,
*/ 
$c = new Doner("4", "testing", "tester", "MA", "33333", "232-232-2323", "121-121-1212", "who@whovill.com" );
$this->assertTrue(add_Doner($c));

/** add a one more
*/
$s = new Doner("5","happy street", "ME", "44444", "434-434-4343", "545-545-5454", "dontknow@wedont.com"  );
$this->assertTrue(add_Doner($s));


/** try to add a duplicate - should return false
*/
$v = new Doner("4", "testing", "tester", "MA", "33333", "232-232-2323", "121-121-1212", "who@whovill.com");
$this->assertFalse(add_Doner($v));

/** get a Doner
*/
$p = get_Doner("2");
$this->assertTrue($p!==null);

/** try to get a Doner who is not in the db
*/
$this->assertFalse(get_Doner("9"));

/** get a different one
*/
$p = get_Doner("5");
$this->assertTrue($p!==null);


/** remove all Doners
*/
$this->assertTrue(remove_Doner("1"));
$this->assertTrue(remove_Doner("2"));
$this->assertTrue(remove_Doner("3"));
$this->assertTrue(remove_Doner("4"));
$this->assertTrue(remove_Doner("5"));

/** try to remove a Doner who is not in the db - should not work
*/
$this->assertFalse(remove_Doner("10"));

echo("testdbDoners complete");
      }
}


?>
